import React,{useEffect} from 'react'
import BuyUi from './BuyUi'
import {useDispatch} from 'react-redux'
import {getlist,getshoes,getclothes} from '../index'
//向组件中传输数据
import { useSelector } from 'react-redux'

export default function BuyContainer() {
    const dispatch =useDispatch()
    const list =useSelector(state=>state.getIn(['buy','list']))
    // const list
    // console.log(list);
    let list2=[]
    for(var i=0;i<list.length;i++){
        // console.log(list[i].product);
        list2.push(list[i].product)
    }
    // console.log(list2);
    const shoes =useSelector(state=>state.getIn(['buy','shoes']))
    let shoes2=[]
    for(var i=0;i<shoes.length;i++){
        // console.log(list[i].product);
        shoes2.push(shoes[i].product)
    }
    const clothes =useSelector(state=>state.getIn(['buy','clothes']))
    let clothes2=[]
    for(var i=0;i<clothes.length;i++){
        // console.log(list[i].product);
        clothes2.push(clothes[i].product)
    }
    const obj={
        list:list2,
        shoes:shoes2,
        clothes:clothes2
    }
    useEffect(()=>{
         dispatch(getlist())
        //  dispatch(getshoes())
        //  dispatch(getclothes())
    },[])
    return (
     <BuyUi obj={obj}></BuyUi>
    )
}
